<template>
  <view class="">
    <!-- <view class="uni-page-head" v-if="titleFlag">
      <image class="common-title-img" style="left: 20rpx;"
             :src="require('../../static/imges/fanhui.png')" @click="back()" />
      <view class="uni-page-head-title">
        出库物资明细
      </view>
    </view> -->
    <!-- <view v-if="titleFlag" style="margin-top: 98rpx;">
    </view> -->
    <view style="width: 100%;">
      <view class="common-body-ex">
        <view class="common-list-ex-patch" style="height: auto;" v-if="type!=='1'">
          <label class="common-list-title-ex">站址编码 :</label>
          <text class="common-list-text-ex-patch" type="text" :selectable="true">{{ outboundDetails.siteId }}</text>
        </view>
        <view class="common-list-ex-patch" style="height: auto;">
          <label class="common-list-title-ex">物料编码 :</label>
          <text class="common-list-text-ex-patch" type="text" :selectable="true">{{ outboundDetails.categoryCode }}</text>
        </view>
        <view class="common-list-ex-patch" style="height: auto;">
          <label class="common-list-title-ex">物料名称 :</label>
          <text class="common-list-text-ex-patch" type="text" :selectable="true">{{ outboundDetails.materialName || outboundDetails.categoryName }}</text>
        </view>
        <view class="table-box">
          <view style="font-weight: 600;display: flex;" >
            <text class="table-box-td" style="width: 40%;">资源资产编码</text>
            <text class="table-box-td" style="width: 40%;">标签ID</text>
            <text class="table-box-td" style="width: 20%;">操作</text>
          </view>
          <view style="display: flex;font-size: 28rpx;" v-for="(item,index) in dataList" :key="index">
            <text class="table-box-td" style="width: 40%;" >{{item.sourceAssetCode}}</text>
            <text class="table-box-td" style="width: 40%;">{{item.labelId}}</text>
            <text class="table-box-td" style="width: 20%;color: #2979ff" @click.stop="checkDetail(item)">查看</text>
          </view>
        </view>
      </view>
    </view>


  </view>
</template>

<script>
// import imp from "../js/imp";

export default {
  data() {
    return {
      dataList: [],
      outboundDetails:{}, // 出库明细
      applyId: '',
      categoryCode: '',
      categoryName: '',
      prjId: '',
      titleFlag: true,
      type: '',
      pageNum: 1,
      total:1,
    }
  },
  // onPullDownRefresh() {
  //   this.getList();
  //   setTimeout(function () {
  //     uni.stopPullDownRefresh()
  //   }, 1000)
  // },
    onReachBottom(){
        console.log(111111)
        this.getList();
    },
  onLoad(option) {
    this.prjId = option.prjId
    this.type = option.type
    //判断新老MOA用来显示导航栏
    if (uni.getStorageSync('moaType') == "0") {
      this.titleFlag = false
    }
    this.outboundDetails = JSON.parse(decodeURIComponent(option.item))
    console.log(JSON.parse(decodeURIComponent(option.item)))
    this.getList();
  },
  onReady() {
    console.log("执行onReady")
    // let menus = [];
    // imp.iWindow.setMenus(menus);
  },
  methods: {
    back() {
      uni.navigateBack({
        delta: 1
      });
    },
    checkDetail(item) {
      uni.navigateTo({
        url: './materialDetail?materialData=' + encodeURIComponent(JSON.stringify(item))
      });
    },


    /**
     * @author: MrLiu
     * @time: 2021-09-15
     * @Title: 工序详情
     */
    getList() {
      // uni.showLoading({
      //   title: '加载中...',
      // mask: true
      // });

      console.log('传入参数' + this.prjId,this.outboundDetails);
      if(this.pageNum <= this.total){
        const params = {
          osDetailId: this.outboundDetails.osDetailId,
          // osDetailId: 'EX202204011656000000130',
          bundingId: this.outboundDetails.bundingId,
          // bundingId: "51750282",
          pageNum: this.pageNum,
          pageSize: 20,
        }
        this.$axios.post('/material/api/retreat/queryAssetLabelDatailList', params).then(res => {
          if (res?.data?.list?.length) {
            this.dataList = this.dataList.concat(res.data.list)
            this.pageNum = this.pageNum + 1;
            this.total = res.data.pages;
            console.log(111,this.dataList,this.pageNum,res.data.pages)
          } else {
            this.dataList = []
            uni.showModal({
              title: "温馨提示",
              content: "没有数据",
              showCancel: false,
              confirmColor:'#eb4b4b',
            });
          }
        })
      }
    }
  }
}
</script>


<style lang="scss" scoped>
@import '@/common/common-ui.css';
.table-box{
  margin-top: 20rpx;
  border-left:2rpx solid rgba(228, 228, 228, 1);
  border-top:2rpx solid rgba(228, 228, 228, 1);
  .table-box-td{
    border-right:2rpx solid rgba(228, 228, 228, 1);
    border-bottom:2rpx solid rgba(228, 228, 228, 1);
    padding: 10rpx;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
</style>
